<template>
	<view class="content" style="padding: 0 1rem;box-sizing: border-box;">
		<u-swiper :list="list2" :autoplay="true" keyName="image" showTitle height="200" circular></u-swiper>
		<view class="" style="margin-top: 1rem;">
			<u-notice-bar bgColor='#EAF2FF' color='#2979FF' :text="text1"></u-notice-bar>
		</view>
		<view style="display: flex;justify-content: space-between;width: 100%;height: 7rem;margin-top: 1rem;">
			<view class="jgq1" @click="handeletuozhi">
				<text>通知公告</text>
			</view>
			<view class="jgq2" @click="handeleusertop">
				<text>身份晋升</text>
			</view>
		</view>
		<u-toast ref="uToast" />
		<view class="" style="text-align: center;border-bottom: 3px solid red;width: 20%;margin: 2rem auto 0rem;">
			热门新闻
		</view>
		<view class="box_one">
			<view class="box_bottom" style="position: relative;" v-for="(item,index) in listrex" :key="index">
				<view style="width: 6rem;height: 6rem;margin-right: 10px;"> 				<image :src="item.coverUrl" mode="" style=""></image></view>
				<view class="box_txt">
					<view class="" style="font-weight: 600;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;width: 0%;width: 100px;">
						{{item.noticeTitle}}
					</view>
					<view class="xianshia" style="xianshia" v-html="item.noticeContent">
					
					</view>
					<view style="position: absolute;right: 20px;bottom: 20px;">
						<u-button type="primary" size="small" @click="lijiguankan" text="立即查看"></u-button>
					</view>

				</view>
			</view>
			
		</view>
		<u-toast ref="uToast"></u-toast>

	</view>
</template>

<script>
	import { baseUrl } from '../../utils/config.js';
export default {
	data() {
		return {
			text1: '中国共产党是中国工人阶级的先锋队，同时是中国人民和中华民族的先锋队，是中国特色社会主义事业的领导核心，代表中国先进生产力的发展要求，代表中国先进文化的前进方向，代表中国最广大人民的根本利益。',
			list2: [{
				image: 'https://cdn.uviewui.com/uview/swiper/swiper2.png',
				title: '昨夜星辰昨夜风，画楼西畔桂堂东',
			}, {
				image: 'https://cdn.uviewui.com/uview/swiper/swiper1.png',
				title: '身无彩凤双飞翼，心有灵犀一点通'
			}, {
				image: 'https://cdn.uviewui.com/uview/swiper/swiper3.png',
				title: '谁念西风独自凉，萧萧黄叶闭疏窗，沉思往事立残阳'
			}],
			ykt_userId: "",
			listrex:[]
		}
	},
	onLoad() {
		this.ykt_userId = uni.getStorageSync('ykt_userId');
		this.getNVM(1)
	},
	methods: {
		getNVM(e) {
			var thas = this
			uni.request({
				url: `${baseUrl}/wechat/system/list`,
				method: 'GET',
				data: {
					noticeType: e
				},
				success(res) {
					console.log(res.data.data,"2121")
					thas.listrex = res.data.data.map(item => {
						return {
							...item,
							coverUrl: baseUrl + item.coverUrl
						}
					})
				},
		
			});
		},
		lijiguankan(row){
			uni.navigateTo({
				url: `/pages/news/add?id=${row.noticeId}`
			});
		},
		handeletuozhi() {
			if (!uni.getStorageSync('ykt_userId')) {
				this.$refs.uToast.show({
					type: 'default',
					message: "去登录",
				})
				uni.switchTab({
					url: '/pages/my/index'
				});
				return
			}
			uni.navigateTo({
				url: "/pages/my/tuozhi"
			});
		},
		handeleusertop() {
			if (!uni.getStorageSync('ykt_userId')) {
				this.$refs.uToast.show({
					type: 'default',
					message: "去登录",
				})
				uni.switchTab({
					url: '/pages/my/index'
				});
				return
			}
			if(uni.getStorageSync('toIdentityLable')=="max"){
				this.$refs.uToast.show({
					type: 'default',
					message: "您已是最高等级，无需申请",
				})
				return

			}
			uni.navigateTo({
				url: "/pages/my/usertop"
			});
		}

	}
}
</script>

<style scoped lang="scss">
.jgq1 {
	width: 45%;
	height: 100%;
	border-radius: 0.4rem;
	// border: 1px solid #fff;
	background-image: url(../../static/live_bg.png);
	background-size: 100% 100%;
	background-repeat: no-repeat;
	font-size: 14px;
	text-align: center;
	color: #333;
	line-height: 10.5rem;
}


.jgq2 {
	width: 45%;
	height: 100%;
	border-radius: 0.4rem;
	// border: 1px solid #fff;
	background-image: url(../../static/course_bg.png);
	background-size: 100% 100%;
	background-repeat: no-repeat;
	font-size: 14px;
	text-align: center;
	color: #333;
	line-height: 10.5rem;
}

.box_one {
	padding: 10px;
	height: 40vh;
	overflow: auto;
}

.box_bottom {
	width: 100%;
	height: 7rem;
	display: flex;
	justify-content: flex-start;
	align-items: center;
	background-color: #fff;
	box-shadow: 0px 0px 3px 0px #ccc;
	border-radius: 0.4rem;
	box-sizing: border-box;
	margin-top: 1rem;

	image {
		width: 6rem;
		height: 6rem;
		margin-left: 10px;
		display: inline-block;
	}

	.box_txt {
		display: flex;
		flex-direction: column;
		justify-content: flex-start;
		margin-left: 10px;
		font-size: 14px;
		color: #333;
		line-height: 30px;
		flex: 1;
		.xianshia{
			overflow: hidden;
			text-overflow: ellipsis;
			display: -webkit-box;
			-webkit-line-clamp: 3; /* 显示行数 */
			-webkit-box-orient: vertical;
			width: 55%;
			line-height: 1rem;
		}
	}
}
</style>